Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TypeSpec APIView] Ensure apiview only triggers on packages directly changed by the pr #31871

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

ckairen
Copy link
Member

@ckairen ckairen commented Dec 13, 2024

closes #31870

@ckairen ckairen added the Central-EngSys This issue is owned by the Engineering System team. label Dec 13, 2024
@ckairen ckairen self-assigned this Dec 13, 2024
Copy link

openapi-pipeline-app bot commented Dec 13, 2024

Next Steps to Merge

Next steps that must be taken to merge this PR:
  • ❌ The required check named Protected Files has failed. Refer to the check in the PR's 'Checks' tab for details on how to fix it and consult the aka.ms/ci-fix guide

Copy link

openapi-pipeline-app bot commented Dec 13, 2024

Generated ApiView

Language Package Name ApiView Link
Go sdk/resourcemanager/contoso/armcontoso https://apiview.dev/Assemblies/Review/19034274c42f494b900a3f8af06c5461?revisionId=dd13f5e1b1c34b838094e37dfc2b112f
Java azure-contoso-widgetmanager https://apiview.dev/Assemblies/Review/182397f33c1742ada71190974ac0d32e?revisionId=da7f7afe72d8498ca3657e22f8d963cd
Java azure-resourcemanager-contoso https://apiview.dev/Assemblies/Review/f958535e0c7e4c1e85a46c1363c6e2bb?revisionId=ff187faf051a4f869a6941cd21a898e4
JavaScript @azure/arm-contoso https://apiview.dev/Assemblies/Review/7667e852608e438dbcca91be6fd43b63?revisionId=ac2c5c940af84b3dacbd7a067f97d8c8
JavaScript @azure-rest/contoso-widgetmanager-rest https://apiview.dev/Assemblies/Review/e9e59bea6b984a4497043899f5cb84b2?revisionId=d73c127947d745659d8e96e005f63871
Python azure-contoso-widgetmanager https://apiview.dev/Assemblies/Review/c69cb49cfc1543cf809dcfcf1b74ff07?revisionId=839edf41a71e429d86b01ce8b5c974f6
Python azure-mgmt-contoso https://apiview.dev/Assemblies/Review/d243e2c15ba74cb899c015e7f2884e54?revisionId=325dab31f0454c4da5bf9c64b296a9ea
.Net Azure.ResourceManager.Contoso https://apiview.dev/Assemblies/Review/7b224f26902a447c92903baab61d49c7?revisionId=0ab1492e5ccd45fcab9e0f3d6ecccb2c
TypeSpec Contoso.Management https://apiview.dev/Assemblies/Review/0fb8a03ff8c348308ed5dc7cce897b08?revisionId=20115a9417704962b0a627e660d7e454
TypeSpec Contoso.WidgetManager https://apiview.dev/Assemblies/Review/5c962afcd8f14aadb4181e69226d99fd?revisionId=97b8ecceeb6c40698d58d1591340a9a8

@azure-sdk
Copy link
Collaborator

azure-sdk commented Dec 13, 2024

API change check

APIView has identified API level changes in this PR and created following API reviews.

Microsoft.Contoso
Azure.Contoso.WidgetManager

@@ -17,12 +17,6 @@ model Employee is TrackedResource<EmployeeProperties> {

/** Employee properties */
model EmployeeProperties {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
model EmployeeProperties {
model EmployeeProperties {
/** Age of employee */
age?: int32;
/** City of employee */
city?: string;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temp removal for testing

@ckairen ckairen marked this pull request as ready for review December 17, 2024 14:55
@praveenkuttappan
Copy link
Member

praveenkuttappan commented Dec 17, 2024

Do we really want to show entire npm package tree in log? This makes it difficult to read the logs that's more important.
For reference, I am talking about: https://dev.azure.com/azure-sdk/public/_build/results?buildId=4410154&view=logs&j=011e1ec8-6569-5e69-4f06-baf193d1351e&t=91baa004-7830-58b9-b0bb-1d930da3801a&l=44

@chidozieononiwu
Copy link
Member

Do we really want to show entire npm package tree in log? This makes it difficult to read the logs that's more important. For reference, I am talking about: https://dev.azure.com/azure-sdk/public/_build/results?buildId=4410154&view=logs&j=011e1ec8-6569-5e69-4f06-baf193d1351e&t=91baa004-7830-58b9-b0bb-1d930da3801a&l=44

You can use the log grouping similar to

LogGroupStart " Generating '$Type' APIView Tokens using '$ReadMeFilePath' for '$ResourceProvider'..."
& $command @arguments 2>&1 | ForEach-Object { Write-Host $_ }
LogGroupEnd

which will hide the lengthy logs in a toggle. That way people can still expand to view it if they want to.

while ($filePathParts.Length -and !$configFilesInTypeSpecProjects) {
$filePathParts = $filePathParts | Select-Object -SkipLast 1
$typeSpecProjectBaseDirectory = $filePathParts -join [IO.Path]::DirectorySeparatorChar
$configFilesInTypeSpecProjects = Get-ChildItem -Path $typeSpecProjectBaseDirectory -File "tspconfig.yaml"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will still be an issue. It is possible to have tspconfig.yaml in sub folders for a shared project. Current logic will stop looking further upwards and move to next block to check if current directory has main.tsp. It won't come back and check again the parent path of current file path if there is no main.tsp.

We can simplify this logic that will work for shared projects also.

for each changed files, strip the prefix before `specification/' from path:

  1. check if current path has tspconfig.yaml and main.tsp.
  2. If yes, add this folder to project set
  3. If no, then go upwards and continue step 2 until we match current path to 'specification/[^\/]+/+`

APIView needs to be generated from paths that contain both main.tsp and tspconfig.yaml (at least to retain same behavior as current one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I don't think I understand the exact situation where this might not work.
The code right now is checking all parent directory of the changed file till we reach root.
line 96 $filePathParts = $filePathParts | Select-Object -SkipLast 1 deletes the leaf directory on each iteration

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update: now using split-path -parent but the iterating logic still remains the same

@microsoft-github-policy-service microsoft-github-policy-service bot added no-recent-activity There has been no recent activity on this issue. and removed no-recent-activity There has been no recent activity on this issue. labels Jan 6, 2025
@chidozieononiwu
Copy link
Member

I disabled the TypeSpec APIView pipeline until this is merged. From my testing I think this PR resolves the TypeSpec project discovery bug but giving there are many ongoing discussions here I will let @ckairen finish it up. For now, the legacy TypeSpec APIView is still running and will generate APIView. This pipeline is causing some confusion at the moment. Please enable re-enable https://dev.azure.com/azure-sdk/public/_build?definitionId=7325 when this is merged.

@@ -31,9 +31,6 @@ model WidgetSuite {
@visibility("read")
name: string;

@doc("The ID of the widget's manufacturer.")
manufacturerId: string;

@doc("The faked shared model.")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@doc("The faked shared model.")
@doc("The ID of the widget's manufacturer.")
manufacturerId: string;
@doc("The faked shared model.")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temp removal for testing 2 directories

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Central-EngSys This issue is owned by the Engineering System team. TypeSpec Authored with TypeSpec
Projects
Status: 🆕 New
Status: 🤔 Triage
Development

Successfully merging this pull request may close these issues.

[TypeSpec APIView] Narrow down typespec apiview to trigger only on changed service
6 participants